// Copyright (c) Lawrence Livermore National Security, LLC and other VisIt
// Project developers.  See the top-level LICENSE file for dates and other
// details.  No copyright assignment is required to contribute to VisIt.

#include <PyVectorAttributes.h>
#include <ObserverToCallback.h>
#include <stdio.h>
#include <Py2and3Support.h>
#include <visit-config.h>
#include <ColorAttribute.h>

// ****************************************************************************
// Module: PyVectorAttributes
//
// Purpose:
//   Attributes for the vector plot
//
// Note:       Autogenerated by xml2python. Do not modify by hand!
//
// Programmer: xml2python
// Creation:   omitted
//
// ****************************************************************************

//
// This struct contains the Python type information and a VectorAttributes.
//
struct VectorAttributesObject
{
    PyObject_HEAD
    VectorAttributes *data;
    bool        owns;
    PyObject   *parent;
};

//
// Internal prototypes
//
static PyObject *NewVectorAttributes(int);
std::string
PyVectorAttributes_ToString(const VectorAttributes *atts, const char *prefix, const bool forLogging)
{
    std::string str;
    char tmpStr[1000];

    const char *glyphLocation_names = "AdaptsToMeshResolution, UniformInSpace";
    switch (atts->GetGlyphLocation())
    {
      case VectorAttributes::AdaptsToMeshResolution:
          snprintf(tmpStr, 1000, "%sglyphLocation = %sAdaptsToMeshResolution  # %s\n", prefix, prefix, glyphLocation_names);
          str += tmpStr;
          break;
      case VectorAttributes::UniformInSpace:
          snprintf(tmpStr, 1000, "%sglyphLocation = %sUniformInSpace  # %s\n", prefix, prefix, glyphLocation_names);
          str += tmpStr;
          break;
      default:
          break;
    }

    if(atts->GetUseStride())
        snprintf(tmpStr, 1000, "%suseStride = 1\n", prefix);
    else
        snprintf(tmpStr, 1000, "%suseStride = 0\n", prefix);
    str += tmpStr;
    snprintf(tmpStr, 1000, "%snVectors = %d\n", prefix, atts->GetNVectors());
    str += tmpStr;
    snprintf(tmpStr, 1000, "%sstride = %d\n", prefix, atts->GetStride());
    str += tmpStr;
    if(atts->GetOrigOnly())
        snprintf(tmpStr, 1000, "%sorigOnly = 1\n", prefix);
    else
        snprintf(tmpStr, 1000, "%sorigOnly = 0\n", prefix);
    str += tmpStr;
    const char *limitsMode_names = "OriginalData, CurrentPlot";
    switch (atts->GetLimitsMode())
    {
      case VectorAttributes::OriginalData:
          snprintf(tmpStr, 1000, "%slimitsMode = %sOriginalData  # %s\n", prefix, prefix, limitsMode_names);
          str += tmpStr;
          break;
      case VectorAttributes::CurrentPlot:
          snprintf(tmpStr, 1000, "%slimitsMode = %sCurrentPlot  # %s\n", prefix, prefix, limitsMode_names);
          str += tmpStr;
          break;
      default:
          break;
    }

    if(atts->GetMinFlag())
        snprintf(tmpStr, 1000, "%sminFlag = 1\n", prefix);
    else
        snprintf(tmpStr, 1000, "%sminFlag = 0\n", prefix);
    str += tmpStr;
    snprintf(tmpStr, 1000, "%smin = %g\n", prefix, atts->GetMin());
    str += tmpStr;
    if(atts->GetMaxFlag())
        snprintf(tmpStr, 1000, "%smaxFlag = 1\n", prefix);
    else
        snprintf(tmpStr, 1000, "%smaxFlag = 0\n", prefix);
    str += tmpStr;
    snprintf(tmpStr, 1000, "%smax = %g\n", prefix, atts->GetMax());
    str += tmpStr;
    if(atts->GetColorByMagnitude())
        snprintf(tmpStr, 1000, "%scolorByMagnitude = 1\n", prefix);
    else
        snprintf(tmpStr, 1000, "%scolorByMagnitude = 0\n", prefix);
    str += tmpStr;
    snprintf(tmpStr, 1000, "%scolorTableName = \"%s\"\n", prefix, atts->GetColorTableName().c_str());
    str += tmpStr;
    if(atts->GetInvertColorTable())
        snprintf(tmpStr, 1000, "%sinvertColorTable = 1\n", prefix);
    else
        snprintf(tmpStr, 1000, "%sinvertColorTable = 0\n", prefix);
    str += tmpStr;
    const unsigned char *vectorColor = atts->GetVectorColor().GetColor();
    snprintf(tmpStr, 1000, "%svectorColor = (%d, %d, %d, %d)\n", prefix, int(vectorColor[0]), int(vectorColor[1]), int(vectorColor[2]), int(vectorColor[3]));
    str += tmpStr;
    if(atts->GetUseLegend())
        snprintf(tmpStr, 1000, "%suseLegend = 1\n", prefix);
    else
        snprintf(tmpStr, 1000, "%suseLegend = 0\n", prefix);
    str += tmpStr;
    snprintf(tmpStr, 1000, "%sscale = %g\n", prefix, atts->GetScale());
    str += tmpStr;
    if(atts->GetScaleByMagnitude())
        snprintf(tmpStr, 1000, "%sscaleByMagnitude = 1\n", prefix);
    else
        snprintf(tmpStr, 1000, "%sscaleByMagnitude = 0\n", prefix);
    str += tmpStr;
    if(atts->GetAutoScale())
        snprintf(tmpStr, 1000, "%sautoScale = 1\n", prefix);
    else
        snprintf(tmpStr, 1000, "%sautoScale = 0\n", prefix);
    str += tmpStr;
    const char *glyphType_names = "Arrow, Ellipsoid";
    switch (atts->GetGlyphType())
    {
      case VectorAttributes::Arrow:
          snprintf(tmpStr, 1000, "%sglyphType = %sArrow  # %s\n", prefix, prefix, glyphType_names);
          str += tmpStr;
          break;
      case VectorAttributes::Ellipsoid:
          snprintf(tmpStr, 1000, "%sglyphType = %sEllipsoid  # %s\n", prefix, prefix, glyphType_names);
          str += tmpStr;
          break;
      default:
          break;
    }

    if(atts->GetHeadOn())
        snprintf(tmpStr, 1000, "%sheadOn = 1\n", prefix);
    else
        snprintf(tmpStr, 1000, "%sheadOn = 0\n", prefix);
    str += tmpStr;
    snprintf(tmpStr, 1000, "%sheadSize = %g\n", prefix, atts->GetHeadSize());
    str += tmpStr;
    const char *lineStem_names = "Cylinder, Line";
    switch (atts->GetLineStem())
    {
      case VectorAttributes::Cylinder:
          snprintf(tmpStr, 1000, "%slineStem = %sCylinder  # %s\n", prefix, prefix, lineStem_names);
          str += tmpStr;
          break;
      case VectorAttributes::Line:
          snprintf(tmpStr, 1000, "%slineStem = %sLine  # %s\n", prefix, prefix, lineStem_names);
          str += tmpStr;
          break;
      default:
          break;
    }

    snprintf(tmpStr, 1000, "%slineWidth = %d\n", prefix, atts->GetLineWidth());
    str += tmpStr;
    snprintf(tmpStr, 1000, "%sstemWidth = %g\n", prefix, atts->GetStemWidth());
    str += tmpStr;
    const char *vectorOrigin_names = "Head, Middle, Tail";
    switch (atts->GetVectorOrigin())
    {
      case VectorAttributes::Head:
          snprintf(tmpStr, 1000, "%svectorOrigin = %sHead  # %s\n", prefix, prefix, vectorOrigin_names);
          str += tmpStr;
          break;
      case VectorAttributes::Middle:
          snprintf(tmpStr, 1000, "%svectorOrigin = %sMiddle  # %s\n", prefix, prefix, vectorOrigin_names);
          str += tmpStr;
          break;
      case VectorAttributes::Tail:
          snprintf(tmpStr, 1000, "%svectorOrigin = %sTail  # %s\n", prefix, prefix, vectorOrigin_names);
          str += tmpStr;
          break;
      default:
          break;
    }

    const char *geometryQuality_names = "Fast, High";
    switch (atts->GetGeometryQuality())
    {
      case VectorAttributes::Fast:
          snprintf(tmpStr, 1000, "%sgeometryQuality = %sFast  # %s\n", prefix, prefix, geometryQuality_names);
          str += tmpStr;
          break;
      case VectorAttributes::High:
          snprintf(tmpStr, 1000, "%sgeometryQuality = %sHigh  # %s\n", prefix, prefix, geometryQuality_names);
          str += tmpStr;
          break;
      default:
          break;
    }

    snprintf(tmpStr, 1000, "%sanimationStep = %d\n", prefix, atts->GetAnimationStep());
    str += tmpStr;
    return str;
}

static PyObject *
VectorAttributes_Notify(PyObject *self, PyObject *args)
{
    VectorAttributesObject *obj = (VectorAttributesObject *)self;
    obj->data->Notify();
    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
VectorAttributes_SetGlyphLocation(PyObject *self, PyObject *args)
{
    VectorAttributesObject *obj = (VectorAttributesObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged into a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyNumber_Check(packaged_args))
            args = packaged_args;
    }

    if (PySequence_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "expecting a single number arg");
    }

    if (!PyNumber_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a number type");
    }

    long val = PyLong_AsLong(args);
    int cval = int(val);

    if ((val == -1 && PyErr_Occurred()) || long(cval) != val)
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as C++ int");
    }

    if (cval < 0 || cval >= 2)
    {
        std::stringstream ss;
        ss << "An invalid glyphLocation value was given." << std::endl;
        ss << "Valid values are in the range [0,1]." << std::endl;
        ss << "You can also use the following symbolic names:";
        ss << " AdaptsToMeshResolution";
        ss << ", UniformInSpace";
        return PyErr_Format(PyExc_ValueError, ss.str().c_str());
    }

    Py_XDECREF(packaged_args);

    // Set the glyphLocation in the object.
    obj->data->SetGlyphLocation(VectorAttributes::GlyphLocation(cval));

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
VectorAttributes_GetGlyphLocation(PyObject *self, PyObject *args)
{
    VectorAttributesObject *obj = (VectorAttributesObject *)self;
    PyObject *retval = PyInt_FromLong(long(obj->data->GetGlyphLocation()));
    return retval;
}

/*static*/ PyObject *
VectorAttributes_SetUseStride(PyObject *self, PyObject *args)
{
    VectorAttributesObject *obj = (VectorAttributesObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged into a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyNumber_Check(packaged_args))
            args = packaged_args;
    }

    if (PySequence_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "expecting a single number arg");
    }

    if (!PyNumber_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a number type");
    }

    long val = PyLong_AsLong(args);
    bool cval = bool(val);

    if (val == -1 && PyErr_Occurred())
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as C++ bool");
    }
    if (fabs(double(val))>1.5E-7 && fabs((double(long(cval))-double(val))/double(val))>1.5E-7)
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_ValueError, "arg not interpretable as C++ bool");
    }

    Py_XDECREF(packaged_args);

    // Set the useStride in the object.
    obj->data->SetUseStride(cval);

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
VectorAttributes_GetUseStride(PyObject *self, PyObject *args)
{
    VectorAttributesObject *obj = (VectorAttributesObject *)self;
    PyObject *retval = PyInt_FromLong(obj->data->GetUseStride()?1L:0L);
    return retval;
}

/*static*/ PyObject *
VectorAttributes_SetNVectors(PyObject *self, PyObject *args)
{
    VectorAttributesObject *obj = (VectorAttributesObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged into a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyNumber_Check(packaged_args))
            args = packaged_args;
    }

    if (PySequence_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "expecting a single number arg");
    }

    if (!PyNumber_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a number type");
    }

    long val = PyLong_AsLong(args);
    int cval = int(val);

    if (val == -1 && PyErr_Occurred())
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as C++ int");
    }
    if (fabs(double(val))>1.5E-7 && fabs((double(long(cval))-double(val))/double(val))>1.5E-7)
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_ValueError, "arg not interpretable as C++ int");
    }

    Py_XDECREF(packaged_args);

    // Set the nVectors in the object.
    obj->data->SetNVectors(cval);

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
VectorAttributes_GetNVectors(PyObject *self, PyObject *args)
{
    VectorAttributesObject *obj = (VectorAttributesObject *)self;
    PyObject *retval = PyInt_FromLong(long(obj->data->GetNVectors()));
    return retval;
}

/*static*/ PyObject *
VectorAttributes_SetStride(PyObject *self, PyObject *args)
{
    VectorAttributesObject *obj = (VectorAttributesObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged into a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyNumber_Check(packaged_args))
            args = packaged_args;
    }

    if (PySequence_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "expecting a single number arg");
    }

    if (!PyNumber_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a number type");
    }

    long val = PyLong_AsLong(args);
    int cval = int(val);

    if (val == -1 && PyErr_Occurred())
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as C++ int");
    }
    if (fabs(double(val))>1.5E-7 && fabs((double(long(cval))-double(val))/double(val))>1.5E-7)
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_ValueError, "arg not interpretable as C++ int");
    }

    Py_XDECREF(packaged_args);

    // Set the stride in the object.
    obj->data->SetStride(cval);

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
VectorAttributes_GetStride(PyObject *self, PyObject *args)
{
    VectorAttributesObject *obj = (VectorAttributesObject *)self;
    PyObject *retval = PyInt_FromLong(long(obj->data->GetStride()));
    return retval;
}

/*static*/ PyObject *
VectorAttributes_SetOrigOnly(PyObject *self, PyObject *args)
{
    VectorAttributesObject *obj = (VectorAttributesObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged into a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyNumber_Check(packaged_args))
            args = packaged_args;
    }

    if (PySequence_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "expecting a single number arg");
    }

    if (!PyNumber_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a number type");
    }

    long val = PyLong_AsLong(args);
    bool cval = bool(val);

    if (val == -1 && PyErr_Occurred())
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as C++ bool");
    }
    if (fabs(double(val))>1.5E-7 && fabs((double(long(cval))-double(val))/double(val))>1.5E-7)
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_ValueError, "arg not interpretable as C++ bool");
    }

    Py_XDECREF(packaged_args);

    // Set the origOnly in the object.
    obj->data->SetOrigOnly(cval);

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
VectorAttributes_GetOrigOnly(PyObject *self, PyObject *args)
{
    VectorAttributesObject *obj = (VectorAttributesObject *)self;
    PyObject *retval = PyInt_FromLong(obj->data->GetOrigOnly()?1L:0L);
    return retval;
}

/*static*/ PyObject *
VectorAttributes_SetLimitsMode(PyObject *self, PyObject *args)
{
    VectorAttributesObject *obj = (VectorAttributesObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged into a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyNumber_Check(packaged_args))
            args = packaged_args;
    }

    if (PySequence_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "expecting a single number arg");
    }

    if (!PyNumber_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a number type");
    }

    long val = PyLong_AsLong(args);
    int cval = int(val);

    if ((val == -1 && PyErr_Occurred()) || long(cval) != val)
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as C++ int");
    }

    if (cval < 0 || cval >= 2)
    {
        std::stringstream ss;
        ss << "An invalid limitsMode value was given." << std::endl;
        ss << "Valid values are in the range [0,1]." << std::endl;
        ss << "You can also use the following symbolic names:";
        ss << " OriginalData";
        ss << ", CurrentPlot";
        return PyErr_Format(PyExc_ValueError, ss.str().c_str());
    }

    Py_XDECREF(packaged_args);

    // Set the limitsMode in the object.
    obj->data->SetLimitsMode(VectorAttributes::LimitsMode(cval));

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
VectorAttributes_GetLimitsMode(PyObject *self, PyObject *args)
{
    VectorAttributesObject *obj = (VectorAttributesObject *)self;
    PyObject *retval = PyInt_FromLong(long(obj->data->GetLimitsMode()));
    return retval;
}

/*static*/ PyObject *
VectorAttributes_SetMinFlag(PyObject *self, PyObject *args)
{
    VectorAttributesObject *obj = (VectorAttributesObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged into a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyNumber_Check(packaged_args))
            args = packaged_args;
    }

    if (PySequence_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "expecting a single number arg");
    }

    if (!PyNumber_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a number type");
    }

    long val = PyLong_AsLong(args);
    bool cval = bool(val);

    if (val == -1 && PyErr_Occurred())
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as C++ bool");
    }
    if (fabs(double(val))>1.5E-7 && fabs((double(long(cval))-double(val))/double(val))>1.5E-7)
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_ValueError, "arg not interpretable as C++ bool");
    }

    Py_XDECREF(packaged_args);

    // Set the minFlag in the object.
    obj->data->SetMinFlag(cval);

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
VectorAttributes_GetMinFlag(PyObject *self, PyObject *args)
{
    VectorAttributesObject *obj = (VectorAttributesObject *)self;
    PyObject *retval = PyInt_FromLong(obj->data->GetMinFlag()?1L:0L);
    return retval;
}

/*static*/ PyObject *
VectorAttributes_SetMin(PyObject *self, PyObject *args)
{
    VectorAttributesObject *obj = (VectorAttributesObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged into a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyNumber_Check(packaged_args))
            args = packaged_args;
    }

    if (PySequence_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "expecting a single number arg");
    }

    if (!PyNumber_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a number type");
    }

    double val = PyFloat_AsDouble(args);
    double cval = double(val);

    if (val == -1 && PyErr_Occurred())
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as C++ double");
    }
    if (fabs(double(val))>1.5E-7 && fabs((double(double(cval))-double(val))/double(val))>1.5E-7)
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_ValueError, "arg not interpretable as C++ double");
    }

    Py_XDECREF(packaged_args);

    // Set the min in the object.
    obj->data->SetMin(cval);

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
VectorAttributes_GetMin(PyObject *self, PyObject *args)
{
    VectorAttributesObject *obj = (VectorAttributesObject *)self;
    PyObject *retval = PyFloat_FromDouble(obj->data->GetMin());
    return retval;
}

/*static*/ PyObject *
VectorAttributes_SetMaxFlag(PyObject *self, PyObject *args)
{
    VectorAttributesObject *obj = (VectorAttributesObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged into a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyNumber_Check(packaged_args))
            args = packaged_args;
    }

    if (PySequence_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "expecting a single number arg");
    }

    if (!PyNumber_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a number type");
    }

    long val = PyLong_AsLong(args);
    bool cval = bool(val);

    if (val == -1 && PyErr_Occurred())
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as C++ bool");
    }
    if (fabs(double(val))>1.5E-7 && fabs((double(long(cval))-double(val))/double(val))>1.5E-7)
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_ValueError, "arg not interpretable as C++ bool");
    }

    Py_XDECREF(packaged_args);

    // Set the maxFlag in the object.
    obj->data->SetMaxFlag(cval);

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
VectorAttributes_GetMaxFlag(PyObject *self, PyObject *args)
{
    VectorAttributesObject *obj = (VectorAttributesObject *)self;
    PyObject *retval = PyInt_FromLong(obj->data->GetMaxFlag()?1L:0L);
    return retval;
}

/*static*/ PyObject *
VectorAttributes_SetMax(PyObject *self, PyObject *args)
{
    VectorAttributesObject *obj = (VectorAttributesObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged into a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyNumber_Check(packaged_args))
            args = packaged_args;
    }

    if (PySequence_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "expecting a single number arg");
    }

    if (!PyNumber_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a number type");
    }

    double val = PyFloat_AsDouble(args);
    double cval = double(val);

    if (val == -1 && PyErr_Occurred())
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as C++ double");
    }
    if (fabs(double(val))>1.5E-7 && fabs((double(double(cval))-double(val))/double(val))>1.5E-7)
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_ValueError, "arg not interpretable as C++ double");
    }

    Py_XDECREF(packaged_args);

    // Set the max in the object.
    obj->data->SetMax(cval);

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
VectorAttributes_GetMax(PyObject *self, PyObject *args)
{
    VectorAttributesObject *obj = (VectorAttributesObject *)self;
    PyObject *retval = PyFloat_FromDouble(obj->data->GetMax());
    return retval;
}

/*static*/ PyObject *
VectorAttributes_SetColorByMagnitude(PyObject *self, PyObject *args)
{
    VectorAttributesObject *obj = (VectorAttributesObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged into a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyNumber_Check(packaged_args))
            args = packaged_args;
    }

    if (PySequence_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "expecting a single number arg");
    }

    if (!PyNumber_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a number type");
    }

    long val = PyLong_AsLong(args);
    bool cval = bool(val);

    if (val == -1 && PyErr_Occurred())
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as C++ bool");
    }
    if (fabs(double(val))>1.5E-7 && fabs((double(long(cval))-double(val))/double(val))>1.5E-7)
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_ValueError, "arg not interpretable as C++ bool");
    }

    Py_XDECREF(packaged_args);

    // Set the colorByMagnitude in the object.
    obj->data->SetColorByMagnitude(cval);

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
VectorAttributes_GetColorByMagnitude(PyObject *self, PyObject *args)
{
    VectorAttributesObject *obj = (VectorAttributesObject *)self;
    PyObject *retval = PyInt_FromLong(obj->data->GetColorByMagnitude()?1L:0L);
    return retval;
}

/*static*/ PyObject *
VectorAttributes_SetColorTableName(PyObject *self, PyObject *args)
{
    VectorAttributesObject *obj = (VectorAttributesObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged as first member of a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyUnicode_Check(packaged_args))
            args = packaged_args;
    }

    if (!PyUnicode_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a unicode string");
    }

    char const *val = PyUnicode_AsUTF8(args);
    std::string cval = std::string(val);

    if (val == 0 && PyErr_Occurred())
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as utf8 string");
    }

    Py_XDECREF(packaged_args);

    // Set the colorTableName in the object.
    obj->data->SetColorTableName(cval);

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
VectorAttributes_GetColorTableName(PyObject *self, PyObject *args)
{
    VectorAttributesObject *obj = (VectorAttributesObject *)self;
    PyObject *retval = PyString_FromString(obj->data->GetColorTableName().c_str());
    return retval;
}

/*static*/ PyObject *
VectorAttributes_SetInvertColorTable(PyObject *self, PyObject *args)
{
    VectorAttributesObject *obj = (VectorAttributesObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged into a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyNumber_Check(packaged_args))
            args = packaged_args;
    }

    if (PySequence_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "expecting a single number arg");
    }

    if (!PyNumber_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a number type");
    }

    long val = PyLong_AsLong(args);
    bool cval = bool(val);

    if (val == -1 && PyErr_Occurred())
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as C++ bool");
    }
    if (fabs(double(val))>1.5E-7 && fabs((double(long(cval))-double(val))/double(val))>1.5E-7)
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_ValueError, "arg not interpretable as C++ bool");
    }

    Py_XDECREF(packaged_args);

    // Set the invertColorTable in the object.
    obj->data->SetInvertColorTable(cval);

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
VectorAttributes_GetInvertColorTable(PyObject *self, PyObject *args)
{
    VectorAttributesObject *obj = (VectorAttributesObject *)self;
    PyObject *retval = PyInt_FromLong(obj->data->GetInvertColorTable()?1L:0L);
    return retval;
}

/*static*/ PyObject *
VectorAttributes_SetVectorColor(PyObject *self, PyObject *args)
{
    VectorAttributesObject *obj = (VectorAttributesObject *)self;

    int c[4];
    if(!PyArg_ParseTuple(args, "iiii", &c[0], &c[1], &c[2], &c[3]))
    {
        c[3] = 255;
        if(!PyArg_ParseTuple(args, "iii", &c[0], &c[1], &c[2]))
        {
            double dr, dg, db, da;
            if(PyArg_ParseTuple(args, "dddd", &dr, &dg, &db, &da))
            {
                c[0] = int(dr);
                c[1] = int(dg);
                c[2] = int(db);
                c[3] = int(da);
            }
            else if(PyArg_ParseTuple(args, "ddd", &dr, &dg, &db))
            {
                c[0] = int(dr);
                c[1] = int(dg);
                c[2] = int(db);
                c[3] = 255;
            }
            else
            {
                PyObject *tuple = NULL;
                if(!PyArg_ParseTuple(args, "O", &tuple))
                    return NULL;

                if(!PyTuple_Check(tuple))
                    return NULL;

                // Make sure that the tuple is the right size.
                if(PyTuple_Size(tuple) < 3 || PyTuple_Size(tuple) > 4)
                    return NULL;

                // Make sure that all elements in the tuple are ints.
                for(int i = 0; i < PyTuple_Size(tuple); ++i)
                {
                    PyObject *item = PyTuple_GET_ITEM(tuple, i);
                    if(PyInt_Check(item))
                        c[i] = int(PyInt_AS_LONG(PyTuple_GET_ITEM(tuple, i)));
                    else if(PyFloat_Check(item))
                        c[i] = int(PyFloat_AS_DOUBLE(PyTuple_GET_ITEM(tuple, i)));
                    else
                        return NULL;
                }
            }
        }
        PyErr_Clear();
    }

    // Set the vectorColor in the object.
    ColorAttribute ca(c[0], c[1], c[2], c[3]);
    obj->data->SetVectorColor(ca);

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
VectorAttributes_GetVectorColor(PyObject *self, PyObject *args)
{
    VectorAttributesObject *obj = (VectorAttributesObject *)self;
    // Allocate a tuple the with enough entries to hold the vectorColor.
    PyObject *retval = PyTuple_New(4);
    const unsigned char *vectorColor = obj->data->GetVectorColor().GetColor();
    PyTuple_SET_ITEM(retval, 0, PyInt_FromLong(long(vectorColor[0])));
    PyTuple_SET_ITEM(retval, 1, PyInt_FromLong(long(vectorColor[1])));
    PyTuple_SET_ITEM(retval, 2, PyInt_FromLong(long(vectorColor[2])));
    PyTuple_SET_ITEM(retval, 3, PyInt_FromLong(long(vectorColor[3])));
    return retval;
}

/*static*/ PyObject *
VectorAttributes_SetUseLegend(PyObject *self, PyObject *args)
{
    VectorAttributesObject *obj = (VectorAttributesObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged into a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyNumber_Check(packaged_args))
            args = packaged_args;
    }

    if (PySequence_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "expecting a single number arg");
    }

    if (!PyNumber_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a number type");
    }

    long val = PyLong_AsLong(args);
    bool cval = bool(val);

    if (val == -1 && PyErr_Occurred())
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as C++ bool");
    }
    if (fabs(double(val))>1.5E-7 && fabs((double(long(cval))-double(val))/double(val))>1.5E-7)
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_ValueError, "arg not interpretable as C++ bool");
    }

    Py_XDECREF(packaged_args);

    // Set the useLegend in the object.
    obj->data->SetUseLegend(cval);

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
VectorAttributes_GetUseLegend(PyObject *self, PyObject *args)
{
    VectorAttributesObject *obj = (VectorAttributesObject *)self;
    PyObject *retval = PyInt_FromLong(obj->data->GetUseLegend()?1L:0L);
    return retval;
}

/*static*/ PyObject *
VectorAttributes_SetScale(PyObject *self, PyObject *args)
{
    VectorAttributesObject *obj = (VectorAttributesObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged into a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyNumber_Check(packaged_args))
            args = packaged_args;
    }

    if (PySequence_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "expecting a single number arg");
    }

    if (!PyNumber_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a number type");
    }

    double val = PyFloat_AsDouble(args);
    double cval = double(val);

    if (val == -1 && PyErr_Occurred())
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as C++ double");
    }
    if (fabs(double(val))>1.5E-7 && fabs((double(double(cval))-double(val))/double(val))>1.5E-7)
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_ValueError, "arg not interpretable as C++ double");
    }

    Py_XDECREF(packaged_args);

    // Set the scale in the object.
    obj->data->SetScale(cval);

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
VectorAttributes_GetScale(PyObject *self, PyObject *args)
{
    VectorAttributesObject *obj = (VectorAttributesObject *)self;
    PyObject *retval = PyFloat_FromDouble(obj->data->GetScale());
    return retval;
}

/*static*/ PyObject *
VectorAttributes_SetScaleByMagnitude(PyObject *self, PyObject *args)
{
    VectorAttributesObject *obj = (VectorAttributesObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged into a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyNumber_Check(packaged_args))
            args = packaged_args;
    }

    if (PySequence_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "expecting a single number arg");
    }

    if (!PyNumber_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a number type");
    }

    long val = PyLong_AsLong(args);
    bool cval = bool(val);

    if (val == -1 && PyErr_Occurred())
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as C++ bool");
    }
    if (fabs(double(val))>1.5E-7 && fabs((double(long(cval))-double(val))/double(val))>1.5E-7)
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_ValueError, "arg not interpretable as C++ bool");
    }

    Py_XDECREF(packaged_args);

    // Set the scaleByMagnitude in the object.
    obj->data->SetScaleByMagnitude(cval);

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
VectorAttributes_GetScaleByMagnitude(PyObject *self, PyObject *args)
{
    VectorAttributesObject *obj = (VectorAttributesObject *)self;
    PyObject *retval = PyInt_FromLong(obj->data->GetScaleByMagnitude()?1L:0L);
    return retval;
}

/*static*/ PyObject *
VectorAttributes_SetAutoScale(PyObject *self, PyObject *args)
{
    VectorAttributesObject *obj = (VectorAttributesObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged into a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyNumber_Check(packaged_args))
            args = packaged_args;
    }

    if (PySequence_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "expecting a single number arg");
    }

    if (!PyNumber_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a number type");
    }

    long val = PyLong_AsLong(args);
    bool cval = bool(val);

    if (val == -1 && PyErr_Occurred())
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as C++ bool");
    }
    if (fabs(double(val))>1.5E-7 && fabs((double(long(cval))-double(val))/double(val))>1.5E-7)
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_ValueError, "arg not interpretable as C++ bool");
    }

    Py_XDECREF(packaged_args);

    // Set the autoScale in the object.
    obj->data->SetAutoScale(cval);

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
VectorAttributes_GetAutoScale(PyObject *self, PyObject *args)
{
    VectorAttributesObject *obj = (VectorAttributesObject *)self;
    PyObject *retval = PyInt_FromLong(obj->data->GetAutoScale()?1L:0L);
    return retval;
}

/*static*/ PyObject *
VectorAttributes_SetGlyphType(PyObject *self, PyObject *args)
{
    VectorAttributesObject *obj = (VectorAttributesObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged into a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyNumber_Check(packaged_args))
            args = packaged_args;
    }

    if (PySequence_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "expecting a single number arg");
    }

    if (!PyNumber_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a number type");
    }

    long val = PyLong_AsLong(args);
    int cval = int(val);

    if ((val == -1 && PyErr_Occurred()) || long(cval) != val)
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as C++ int");
    }

    if (cval < 0 || cval >= 2)
    {
        std::stringstream ss;
        ss << "An invalid glyphType value was given." << std::endl;
        ss << "Valid values are in the range [0,1]." << std::endl;
        ss << "You can also use the following symbolic names:";
        ss << " Arrow";
        ss << ", Ellipsoid";
        return PyErr_Format(PyExc_ValueError, ss.str().c_str());
    }

    Py_XDECREF(packaged_args);

    // Set the glyphType in the object.
    obj->data->SetGlyphType(VectorAttributes::GlyphType(cval));

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
VectorAttributes_GetGlyphType(PyObject *self, PyObject *args)
{
    VectorAttributesObject *obj = (VectorAttributesObject *)self;
    PyObject *retval = PyInt_FromLong(long(obj->data->GetGlyphType()));
    return retval;
}

/*static*/ PyObject *
VectorAttributes_SetHeadOn(PyObject *self, PyObject *args)
{
    VectorAttributesObject *obj = (VectorAttributesObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged into a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyNumber_Check(packaged_args))
            args = packaged_args;
    }

    if (PySequence_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "expecting a single number arg");
    }

    if (!PyNumber_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a number type");
    }

    long val = PyLong_AsLong(args);
    bool cval = bool(val);

    if (val == -1 && PyErr_Occurred())
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as C++ bool");
    }
    if (fabs(double(val))>1.5E-7 && fabs((double(long(cval))-double(val))/double(val))>1.5E-7)
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_ValueError, "arg not interpretable as C++ bool");
    }

    Py_XDECREF(packaged_args);

    // Set the headOn in the object.
    obj->data->SetHeadOn(cval);

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
VectorAttributes_GetHeadOn(PyObject *self, PyObject *args)
{
    VectorAttributesObject *obj = (VectorAttributesObject *)self;
    PyObject *retval = PyInt_FromLong(obj->data->GetHeadOn()?1L:0L);
    return retval;
}

/*static*/ PyObject *
VectorAttributes_SetHeadSize(PyObject *self, PyObject *args)
{
    VectorAttributesObject *obj = (VectorAttributesObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged into a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyNumber_Check(packaged_args))
            args = packaged_args;
    }

    if (PySequence_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "expecting a single number arg");
    }

    if (!PyNumber_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a number type");
    }

    double val = PyFloat_AsDouble(args);
    double cval = double(val);

    if (val == -1 && PyErr_Occurred())
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as C++ double");
    }
    if (fabs(double(val))>1.5E-7 && fabs((double(double(cval))-double(val))/double(val))>1.5E-7)
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_ValueError, "arg not interpretable as C++ double");
    }

    Py_XDECREF(packaged_args);

    // Set the headSize in the object.
    obj->data->SetHeadSize(cval);

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
VectorAttributes_GetHeadSize(PyObject *self, PyObject *args)
{
    VectorAttributesObject *obj = (VectorAttributesObject *)self;
    PyObject *retval = PyFloat_FromDouble(obj->data->GetHeadSize());
    return retval;
}

/*static*/ PyObject *
VectorAttributes_SetLineStem(PyObject *self, PyObject *args)
{
    VectorAttributesObject *obj = (VectorAttributesObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged into a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyNumber_Check(packaged_args))
            args = packaged_args;
    }

    if (PySequence_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "expecting a single number arg");
    }

    if (!PyNumber_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a number type");
    }

    long val = PyLong_AsLong(args);
    int cval = int(val);

    if ((val == -1 && PyErr_Occurred()) || long(cval) != val)
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as C++ int");
    }

    if (cval < 0 || cval >= 2)
    {
        std::stringstream ss;
        ss << "An invalid lineStem value was given." << std::endl;
        ss << "Valid values are in the range [0,1]." << std::endl;
        ss << "You can also use the following symbolic names:";
        ss << " Cylinder";
        ss << ", Line";
        return PyErr_Format(PyExc_ValueError, ss.str().c_str());
    }

    Py_XDECREF(packaged_args);

    // Set the lineStem in the object.
    obj->data->SetLineStem(VectorAttributes::LineStem(cval));

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
VectorAttributes_GetLineStem(PyObject *self, PyObject *args)
{
    VectorAttributesObject *obj = (VectorAttributesObject *)self;
    PyObject *retval = PyInt_FromLong(long(obj->data->GetLineStem()));
    return retval;
}

/*static*/ PyObject *
VectorAttributes_SetLineWidth(PyObject *self, PyObject *args)
{
    VectorAttributesObject *obj = (VectorAttributesObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged into a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyNumber_Check(packaged_args))
            args = packaged_args;
    }

    if (PySequence_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "expecting a single number arg");
    }

    if (!PyNumber_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a number type");
    }

    long val = PyLong_AsLong(args);
    int cval = int(val);

    if (val == -1 && PyErr_Occurred())
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as C++ int");
    }
    if (fabs(double(val))>1.5E-7 && fabs((double(long(cval))-double(val))/double(val))>1.5E-7)
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_ValueError, "arg not interpretable as C++ int");
    }

    Py_XDECREF(packaged_args);

    // Set the lineWidth in the object.
    obj->data->SetLineWidth(cval);

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
VectorAttributes_GetLineWidth(PyObject *self, PyObject *args)
{
    VectorAttributesObject *obj = (VectorAttributesObject *)self;
    PyObject *retval = PyInt_FromLong(long(obj->data->GetLineWidth()));
    return retval;
}

/*static*/ PyObject *
VectorAttributes_SetStemWidth(PyObject *self, PyObject *args)
{
    VectorAttributesObject *obj = (VectorAttributesObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged into a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyNumber_Check(packaged_args))
            args = packaged_args;
    }

    if (PySequence_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "expecting a single number arg");
    }

    if (!PyNumber_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a number type");
    }

    double val = PyFloat_AsDouble(args);
    double cval = double(val);

    if (val == -1 && PyErr_Occurred())
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as C++ double");
    }
    if (fabs(double(val))>1.5E-7 && fabs((double(double(cval))-double(val))/double(val))>1.5E-7)
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_ValueError, "arg not interpretable as C++ double");
    }

    Py_XDECREF(packaged_args);

    // Set the stemWidth in the object.
    obj->data->SetStemWidth(cval);

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
VectorAttributes_GetStemWidth(PyObject *self, PyObject *args)
{
    VectorAttributesObject *obj = (VectorAttributesObject *)self;
    PyObject *retval = PyFloat_FromDouble(obj->data->GetStemWidth());
    return retval;
}

/*static*/ PyObject *
VectorAttributes_SetVectorOrigin(PyObject *self, PyObject *args)
{
    VectorAttributesObject *obj = (VectorAttributesObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged into a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyNumber_Check(packaged_args))
            args = packaged_args;
    }

    if (PySequence_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "expecting a single number arg");
    }

    if (!PyNumber_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a number type");
    }

    long val = PyLong_AsLong(args);
    int cval = int(val);

    if ((val == -1 && PyErr_Occurred()) || long(cval) != val)
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as C++ int");
    }

    if (cval < 0 || cval >= 3)
    {
        std::stringstream ss;
        ss << "An invalid vectorOrigin value was given." << std::endl;
        ss << "Valid values are in the range [0,2]." << std::endl;
        ss << "You can also use the following symbolic names:";
        ss << " Head";
        ss << ", Middle";
        ss << ", Tail";
        return PyErr_Format(PyExc_ValueError, ss.str().c_str());
    }

    Py_XDECREF(packaged_args);

    // Set the vectorOrigin in the object.
    obj->data->SetVectorOrigin(VectorAttributes::OriginType(cval));

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
VectorAttributes_GetVectorOrigin(PyObject *self, PyObject *args)
{
    VectorAttributesObject *obj = (VectorAttributesObject *)self;
    PyObject *retval = PyInt_FromLong(long(obj->data->GetVectorOrigin()));
    return retval;
}

/*static*/ PyObject *
VectorAttributes_SetGeometryQuality(PyObject *self, PyObject *args)
{
    VectorAttributesObject *obj = (VectorAttributesObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged into a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyNumber_Check(packaged_args))
            args = packaged_args;
    }

    if (PySequence_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "expecting a single number arg");
    }

    if (!PyNumber_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a number type");
    }

    long val = PyLong_AsLong(args);
    int cval = int(val);

    if ((val == -1 && PyErr_Occurred()) || long(cval) != val)
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as C++ int");
    }

    if (cval < 0 || cval >= 2)
    {
        std::stringstream ss;
        ss << "An invalid geometryQuality value was given." << std::endl;
        ss << "Valid values are in the range [0,1]." << std::endl;
        ss << "You can also use the following symbolic names:";
        ss << " Fast";
        ss << ", High";
        return PyErr_Format(PyExc_ValueError, ss.str().c_str());
    }

    Py_XDECREF(packaged_args);

    // Set the geometryQuality in the object.
    obj->data->SetGeometryQuality(VectorAttributes::Quality(cval));

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
VectorAttributes_GetGeometryQuality(PyObject *self, PyObject *args)
{
    VectorAttributesObject *obj = (VectorAttributesObject *)self;
    PyObject *retval = PyInt_FromLong(long(obj->data->GetGeometryQuality()));
    return retval;
}

/*static*/ PyObject *
VectorAttributes_SetAnimationStep(PyObject *self, PyObject *args)
{
    VectorAttributesObject *obj = (VectorAttributesObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged into a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyNumber_Check(packaged_args))
            args = packaged_args;
    }

    if (PySequence_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "expecting a single number arg");
    }

    if (!PyNumber_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a number type");
    }

    long val = PyLong_AsLong(args);
    int cval = int(val);

    if (val == -1 && PyErr_Occurred())
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as C++ int");
    }
    if (fabs(double(val))>1.5E-7 && fabs((double(long(cval))-double(val))/double(val))>1.5E-7)
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_ValueError, "arg not interpretable as C++ int");
    }

    Py_XDECREF(packaged_args);

    // Set the animationStep in the object.
    obj->data->SetAnimationStep(cval);

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
VectorAttributes_GetAnimationStep(PyObject *self, PyObject *args)
{
    VectorAttributesObject *obj = (VectorAttributesObject *)self;
    PyObject *retval = PyInt_FromLong(long(obj->data->GetAnimationStep()));
    return retval;
}



PyMethodDef PyVectorAttributes_methods[VECTORATTRIBUTES_NMETH] = {
    {"Notify", VectorAttributes_Notify, METH_VARARGS},
    {"SetGlyphLocation", VectorAttributes_SetGlyphLocation, METH_VARARGS},
    {"GetGlyphLocation", VectorAttributes_GetGlyphLocation, METH_VARARGS},
    {"SetUseStride", VectorAttributes_SetUseStride, METH_VARARGS},
    {"GetUseStride", VectorAttributes_GetUseStride, METH_VARARGS},
    {"SetNVectors", VectorAttributes_SetNVectors, METH_VARARGS},
    {"GetNVectors", VectorAttributes_GetNVectors, METH_VARARGS},
    {"SetStride", VectorAttributes_SetStride, METH_VARARGS},
    {"GetStride", VectorAttributes_GetStride, METH_VARARGS},
    {"SetOrigOnly", VectorAttributes_SetOrigOnly, METH_VARARGS},
    {"GetOrigOnly", VectorAttributes_GetOrigOnly, METH_VARARGS},
    {"SetLimitsMode", VectorAttributes_SetLimitsMode, METH_VARARGS},
    {"GetLimitsMode", VectorAttributes_GetLimitsMode, METH_VARARGS},
    {"SetMinFlag", VectorAttributes_SetMinFlag, METH_VARARGS},
    {"GetMinFlag", VectorAttributes_GetMinFlag, METH_VARARGS},
    {"SetMin", VectorAttributes_SetMin, METH_VARARGS},
    {"GetMin", VectorAttributes_GetMin, METH_VARARGS},
    {"SetMaxFlag", VectorAttributes_SetMaxFlag, METH_VARARGS},
    {"GetMaxFlag", VectorAttributes_GetMaxFlag, METH_VARARGS},
    {"SetMax", VectorAttributes_SetMax, METH_VARARGS},
    {"GetMax", VectorAttributes_GetMax, METH_VARARGS},
    {"SetColorByMagnitude", VectorAttributes_SetColorByMagnitude, METH_VARARGS},
    {"GetColorByMagnitude", VectorAttributes_GetColorByMagnitude, METH_VARARGS},
    {"SetColorTableName", VectorAttributes_SetColorTableName, METH_VARARGS},
    {"GetColorTableName", VectorAttributes_GetColorTableName, METH_VARARGS},
    {"SetInvertColorTable", VectorAttributes_SetInvertColorTable, METH_VARARGS},
    {"GetInvertColorTable", VectorAttributes_GetInvertColorTable, METH_VARARGS},
    {"SetVectorColor", VectorAttributes_SetVectorColor, METH_VARARGS},
    {"GetVectorColor", VectorAttributes_GetVectorColor, METH_VARARGS},
    {"SetUseLegend", VectorAttributes_SetUseLegend, METH_VARARGS},
    {"GetUseLegend", VectorAttributes_GetUseLegend, METH_VARARGS},
    {"SetScale", VectorAttributes_SetScale, METH_VARARGS},
    {"GetScale", VectorAttributes_GetScale, METH_VARARGS},
    {"SetScaleByMagnitude", VectorAttributes_SetScaleByMagnitude, METH_VARARGS},
    {"GetScaleByMagnitude", VectorAttributes_GetScaleByMagnitude, METH_VARARGS},
    {"SetAutoScale", VectorAttributes_SetAutoScale, METH_VARARGS},
    {"GetAutoScale", VectorAttributes_GetAutoScale, METH_VARARGS},
    {"SetGlyphType", VectorAttributes_SetGlyphType, METH_VARARGS},
    {"GetGlyphType", VectorAttributes_GetGlyphType, METH_VARARGS},
    {"SetHeadOn", VectorAttributes_SetHeadOn, METH_VARARGS},
    {"GetHeadOn", VectorAttributes_GetHeadOn, METH_VARARGS},
    {"SetHeadSize", VectorAttributes_SetHeadSize, METH_VARARGS},
    {"GetHeadSize", VectorAttributes_GetHeadSize, METH_VARARGS},
    {"SetLineStem", VectorAttributes_SetLineStem, METH_VARARGS},
    {"GetLineStem", VectorAttributes_GetLineStem, METH_VARARGS},
    {"SetLineWidth", VectorAttributes_SetLineWidth, METH_VARARGS},
    {"GetLineWidth", VectorAttributes_GetLineWidth, METH_VARARGS},
    {"SetStemWidth", VectorAttributes_SetStemWidth, METH_VARARGS},
    {"GetStemWidth", VectorAttributes_GetStemWidth, METH_VARARGS},
    {"SetVectorOrigin", VectorAttributes_SetVectorOrigin, METH_VARARGS},
    {"GetVectorOrigin", VectorAttributes_GetVectorOrigin, METH_VARARGS},
    {"SetGeometryQuality", VectorAttributes_SetGeometryQuality, METH_VARARGS},
    {"GetGeometryQuality", VectorAttributes_GetGeometryQuality, METH_VARARGS},
    {"SetAnimationStep", VectorAttributes_SetAnimationStep, METH_VARARGS},
    {"GetAnimationStep", VectorAttributes_GetAnimationStep, METH_VARARGS},
    {NULL, NULL}
};

//
// Type functions
//

static void
VectorAttributes_dealloc(PyObject *v)
{
   VectorAttributesObject *obj = (VectorAttributesObject *)v;
   if(obj->parent != 0)
       Py_DECREF(obj->parent);
   if(obj->owns)
       delete obj->data;
}

static PyObject *VectorAttributes_richcompare(PyObject *self, PyObject *other, int op);
PyObject *
PyVectorAttributes_getattr(PyObject *self, char *name)
{
    if(strcmp(name, "glyphLocation") == 0)
        return VectorAttributes_GetGlyphLocation(self, NULL);
    if(strcmp(name, "AdaptsToMeshResolution") == 0)
        return PyInt_FromLong(long(VectorAttributes::AdaptsToMeshResolution));
    if(strcmp(name, "UniformInSpace") == 0)
        return PyInt_FromLong(long(VectorAttributes::UniformInSpace));

    if(strcmp(name, "useStride") == 0)
        return VectorAttributes_GetUseStride(self, NULL);
    if(strcmp(name, "nVectors") == 0)
        return VectorAttributes_GetNVectors(self, NULL);
    if(strcmp(name, "stride") == 0)
        return VectorAttributes_GetStride(self, NULL);
    if(strcmp(name, "origOnly") == 0)
        return VectorAttributes_GetOrigOnly(self, NULL);
    if(strcmp(name, "limitsMode") == 0)
        return VectorAttributes_GetLimitsMode(self, NULL);
    if(strcmp(name, "OriginalData") == 0)
        return PyInt_FromLong(long(VectorAttributes::OriginalData));
    if(strcmp(name, "CurrentPlot") == 0)
        return PyInt_FromLong(long(VectorAttributes::CurrentPlot));

    if(strcmp(name, "minFlag") == 0)
        return VectorAttributes_GetMinFlag(self, NULL);
    if(strcmp(name, "min") == 0)
        return VectorAttributes_GetMin(self, NULL);
    if(strcmp(name, "maxFlag") == 0)
        return VectorAttributes_GetMaxFlag(self, NULL);
    if(strcmp(name, "max") == 0)
        return VectorAttributes_GetMax(self, NULL);
    if(strcmp(name, "colorByMagnitude") == 0)
        return VectorAttributes_GetColorByMagnitude(self, NULL);
    if(strcmp(name, "colorTableName") == 0)
        return VectorAttributes_GetColorTableName(self, NULL);
    if(strcmp(name, "invertColorTable") == 0)
        return VectorAttributes_GetInvertColorTable(self, NULL);
    if(strcmp(name, "vectorColor") == 0)
        return VectorAttributes_GetVectorColor(self, NULL);
    if(strcmp(name, "useLegend") == 0)
        return VectorAttributes_GetUseLegend(self, NULL);
    if(strcmp(name, "scale") == 0)
        return VectorAttributes_GetScale(self, NULL);
    if(strcmp(name, "scaleByMagnitude") == 0)
        return VectorAttributes_GetScaleByMagnitude(self, NULL);
    if(strcmp(name, "autoScale") == 0)
        return VectorAttributes_GetAutoScale(self, NULL);
    if(strcmp(name, "glyphType") == 0)
        return VectorAttributes_GetGlyphType(self, NULL);
    if(strcmp(name, "Arrow") == 0)
        return PyInt_FromLong(long(VectorAttributes::Arrow));
    if(strcmp(name, "Ellipsoid") == 0)
        return PyInt_FromLong(long(VectorAttributes::Ellipsoid));

    if(strcmp(name, "headOn") == 0)
        return VectorAttributes_GetHeadOn(self, NULL);
    if(strcmp(name, "headSize") == 0)
        return VectorAttributes_GetHeadSize(self, NULL);
    if(strcmp(name, "lineStem") == 0)
        return VectorAttributes_GetLineStem(self, NULL);
    if(strcmp(name, "Cylinder") == 0)
        return PyInt_FromLong(long(VectorAttributes::Cylinder));
    if(strcmp(name, "Line") == 0)
        return PyInt_FromLong(long(VectorAttributes::Line));

    if(strcmp(name, "lineWidth") == 0)
        return VectorAttributes_GetLineWidth(self, NULL);
    if(strcmp(name, "stemWidth") == 0)
        return VectorAttributes_GetStemWidth(self, NULL);
    if(strcmp(name, "vectorOrigin") == 0)
        return VectorAttributes_GetVectorOrigin(self, NULL);
    if(strcmp(name, "Head") == 0)
        return PyInt_FromLong(long(VectorAttributes::Head));
    if(strcmp(name, "Middle") == 0)
        return PyInt_FromLong(long(VectorAttributes::Middle));
    if(strcmp(name, "Tail") == 0)
        return PyInt_FromLong(long(VectorAttributes::Tail));

    if(strcmp(name, "geometryQuality") == 0)
        return VectorAttributes_GetGeometryQuality(self, NULL);
    if(strcmp(name, "Fast") == 0)
        return PyInt_FromLong(long(VectorAttributes::Fast));
    if(strcmp(name, "High") == 0)
        return PyInt_FromLong(long(VectorAttributes::High));

    if(strcmp(name, "animationStep") == 0)
        return VectorAttributes_GetAnimationStep(self, NULL);


    // Add a __dict__ answer so that dir() works
    if (!strcmp(name, "__dict__"))
    {
        PyObject *result = PyDict_New();
        for (int i = 0; PyVectorAttributes_methods[i].ml_meth; i++)
            PyDict_SetItem(result,
                PyString_FromString(PyVectorAttributes_methods[i].ml_name),
                PyString_FromString(PyVectorAttributes_methods[i].ml_name));
        return result;
    }

    return Py_FindMethod(PyVectorAttributes_methods, self, name);
}

int
PyVectorAttributes_setattr(PyObject *self, char *name, PyObject *args)
{
    PyObject NULL_PY_OBJ;
    PyObject *obj = &NULL_PY_OBJ;

    if(strcmp(name, "glyphLocation") == 0)
        obj = VectorAttributes_SetGlyphLocation(self, args);
    else if(strcmp(name, "useStride") == 0)
        obj = VectorAttributes_SetUseStride(self, args);
    else if(strcmp(name, "nVectors") == 0)
        obj = VectorAttributes_SetNVectors(self, args);
    else if(strcmp(name, "stride") == 0)
        obj = VectorAttributes_SetStride(self, args);
    else if(strcmp(name, "origOnly") == 0)
        obj = VectorAttributes_SetOrigOnly(self, args);
    else if(strcmp(name, "limitsMode") == 0)
        obj = VectorAttributes_SetLimitsMode(self, args);
    else if(strcmp(name, "minFlag") == 0)
        obj = VectorAttributes_SetMinFlag(self, args);
    else if(strcmp(name, "min") == 0)
        obj = VectorAttributes_SetMin(self, args);
    else if(strcmp(name, "maxFlag") == 0)
        obj = VectorAttributes_SetMaxFlag(self, args);
    else if(strcmp(name, "max") == 0)
        obj = VectorAttributes_SetMax(self, args);
    else if(strcmp(name, "colorByMagnitude") == 0)
        obj = VectorAttributes_SetColorByMagnitude(self, args);
    else if(strcmp(name, "colorTableName") == 0)
        obj = VectorAttributes_SetColorTableName(self, args);
    else if(strcmp(name, "invertColorTable") == 0)
        obj = VectorAttributes_SetInvertColorTable(self, args);
    else if(strcmp(name, "vectorColor") == 0)
        obj = VectorAttributes_SetVectorColor(self, args);
    else if(strcmp(name, "useLegend") == 0)
        obj = VectorAttributes_SetUseLegend(self, args);
    else if(strcmp(name, "scale") == 0)
        obj = VectorAttributes_SetScale(self, args);
    else if(strcmp(name, "scaleByMagnitude") == 0)
        obj = VectorAttributes_SetScaleByMagnitude(self, args);
    else if(strcmp(name, "autoScale") == 0)
        obj = VectorAttributes_SetAutoScale(self, args);
    else if(strcmp(name, "glyphType") == 0)
        obj = VectorAttributes_SetGlyphType(self, args);
    else if(strcmp(name, "headOn") == 0)
        obj = VectorAttributes_SetHeadOn(self, args);
    else if(strcmp(name, "headSize") == 0)
        obj = VectorAttributes_SetHeadSize(self, args);
    else if(strcmp(name, "lineStem") == 0)
        obj = VectorAttributes_SetLineStem(self, args);
    else if(strcmp(name, "lineWidth") == 0)
        obj = VectorAttributes_SetLineWidth(self, args);
    else if(strcmp(name, "stemWidth") == 0)
        obj = VectorAttributes_SetStemWidth(self, args);
    else if(strcmp(name, "vectorOrigin") == 0)
        obj = VectorAttributes_SetVectorOrigin(self, args);
    else if(strcmp(name, "geometryQuality") == 0)
        obj = VectorAttributes_SetGeometryQuality(self, args);
    else if(strcmp(name, "animationStep") == 0)
        obj = VectorAttributes_SetAnimationStep(self, args);

    if (obj != NULL && obj != &NULL_PY_OBJ)
        Py_DECREF(obj);

    if (obj == &NULL_PY_OBJ)
    {
        obj = NULL;
        PyErr_Format(PyExc_NameError, "name '%s' is not defined", name);
    }
    else if (obj == NULL && !PyErr_Occurred())
        PyErr_Format(PyExc_RuntimeError, "unknown problem with '%s'", name);

    return (obj != NULL) ? 0 : -1;
}

static int
VectorAttributes_print(PyObject *v, FILE *fp, int flags)
{
    VectorAttributesObject *obj = (VectorAttributesObject *)v;
    fprintf(fp, "%s", PyVectorAttributes_ToString(obj->data, "",false).c_str());
    return 0;
}

PyObject *
VectorAttributes_str(PyObject *v)
{
    VectorAttributesObject *obj = (VectorAttributesObject *)v;
    return PyString_FromString(PyVectorAttributes_ToString(obj->data,"", false).c_str());
}

//
// The doc string for the class.
//
#if PY_MAJOR_VERSION > 2 || (PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION >= 5)
static const char *VectorAttributes_Purpose = "Attributes for the vector plot";
#else
static char *VectorAttributes_Purpose = "Attributes for the vector plot";
#endif

//
// Python Type Struct Def Macro from Py2and3Support.h
//
//         VISIT_PY_TYPE_OBJ( VPY_TYPE,
//                            VPY_NAME,
//                            VPY_OBJECT,
//                            VPY_DEALLOC,
//                            VPY_PRINT,
//                            VPY_GETATTR,
//                            VPY_SETATTR,
//                            VPY_STR,
//                            VPY_PURPOSE,
//                            VPY_RICHCOMP,
//                            VPY_AS_NUMBER)

//
// The type description structure
//

VISIT_PY_TYPE_OBJ(VectorAttributesType,         \
                  "VectorAttributes",           \
                  VectorAttributesObject,       \
                  VectorAttributes_dealloc,     \
                  VectorAttributes_print,       \
                  PyVectorAttributes_getattr,   \
                  PyVectorAttributes_setattr,   \
                  VectorAttributes_str,         \
                  VectorAttributes_Purpose,     \
                  VectorAttributes_richcompare, \
                  0); /* as_number*/

//
// Helper function for comparing.
//
static PyObject *
VectorAttributes_richcompare(PyObject *self, PyObject *other, int op)
{
    // only compare against the same type 
    if ( Py_TYPE(self) != &VectorAttributesType
         || Py_TYPE(other) != &VectorAttributesType)
    {
        Py_INCREF(Py_NotImplemented);
        return Py_NotImplemented;
    }

    PyObject *res = NULL;
    VectorAttributes *a = ((VectorAttributesObject *)self)->data;
    VectorAttributes *b = ((VectorAttributesObject *)other)->data;

    switch (op)
    {
       case Py_EQ:
           res = (*a == *b) ? Py_True : Py_False;
           break;
       case Py_NE:
           res = (*a != *b) ? Py_True : Py_False;
           break;
       default:
           res = Py_NotImplemented;
           break;
    }

    Py_INCREF(res);
    return res;
}

//
// Helper functions for object allocation.
//

static VectorAttributes *defaultAtts = 0;
static VectorAttributes *currentAtts = 0;

static PyObject *
NewVectorAttributes(int useCurrent)
{
    VectorAttributesObject *newObject;
    newObject = PyObject_NEW(VectorAttributesObject, &VectorAttributesType);
    if(newObject == NULL)
        return NULL;
    if(useCurrent && currentAtts != 0)
        newObject->data = new VectorAttributes(*currentAtts);
    else if(defaultAtts != 0)
        newObject->data = new VectorAttributes(*defaultAtts);
    else
        newObject->data = new VectorAttributes;
    newObject->owns = true;
    newObject->parent = 0;
    return (PyObject *)newObject;
}

static PyObject *
WrapVectorAttributes(const VectorAttributes *attr)
{
    VectorAttributesObject *newObject;
    newObject = PyObject_NEW(VectorAttributesObject, &VectorAttributesType);
    if(newObject == NULL)
        return NULL;
    newObject->data = (VectorAttributes *)attr;
    newObject->owns = false;
    newObject->parent = 0;
    return (PyObject *)newObject;
}

///////////////////////////////////////////////////////////////////////////////
//
// Interface that is exposed to the VisIt module.
//
///////////////////////////////////////////////////////////////////////////////

PyObject *
VectorAttributes_new(PyObject *self, PyObject *args)
{
    int useCurrent = 0;
    if (!PyArg_ParseTuple(args, "i", &useCurrent))
    {
        if (!PyArg_ParseTuple(args, ""))
            return NULL;
        else
            PyErr_Clear();
    }

    return (PyObject *)NewVectorAttributes(useCurrent);
}

//
// Plugin method table. These methods are added to the visitmodule's methods.
//
static PyMethodDef VectorAttributesMethods[] = {
    {"VectorAttributes", VectorAttributes_new, METH_VARARGS},
    {NULL,      NULL}        /* Sentinel */
};

static Observer *VectorAttributesObserver = 0;

std::string
PyVectorAttributes_GetLogString()
{
    std::string s("VectorAtts = VectorAttributes()\n");
    if(currentAtts != 0)
        s += PyVectorAttributes_ToString(currentAtts, "VectorAtts.", true);
    return s;
}

static void
PyVectorAttributes_CallLogRoutine(Subject *subj, void *data)
{
    typedef void (*logCallback)(const std::string &);
    logCallback cb = (logCallback)data;

    if(cb != 0)
    {
        std::string s("VectorAtts = VectorAttributes()\n");
        s += PyVectorAttributes_ToString(currentAtts, "VectorAtts.", true);
        cb(s);
    }
}

void
PyVectorAttributes_StartUp(VectorAttributes *subj, void *data)
{
    if(subj == 0)
        return;

    currentAtts = subj;
    PyVectorAttributes_SetDefaults(subj);

    //
    // Create the observer that will be notified when the attributes change.
    //
    if(VectorAttributesObserver == 0)
    {
        VectorAttributesObserver = new ObserverToCallback(subj,
            PyVectorAttributes_CallLogRoutine, (void *)data);
    }

}

void
PyVectorAttributes_CloseDown()
{
    delete defaultAtts;
    defaultAtts = 0;
    delete VectorAttributesObserver;
    VectorAttributesObserver = 0;
}

PyMethodDef *
PyVectorAttributes_GetMethodTable(int *nMethods)
{
    *nMethods = 1;
    return VectorAttributesMethods;
}

bool
PyVectorAttributes_Check(PyObject *obj)
{
    return (obj->ob_type == &VectorAttributesType);
}

VectorAttributes *
PyVectorAttributes_FromPyObject(PyObject *obj)
{
    VectorAttributesObject *obj2 = (VectorAttributesObject *)obj;
    return obj2->data;
}

PyObject *
PyVectorAttributes_New()
{
    return NewVectorAttributes(0);
}

PyObject *
PyVectorAttributes_Wrap(const VectorAttributes *attr)
{
    return WrapVectorAttributes(attr);
}

void
PyVectorAttributes_SetParent(PyObject *obj, PyObject *parent)
{
    VectorAttributesObject *obj2 = (VectorAttributesObject *)obj;
    obj2->parent = parent;
}

void
PyVectorAttributes_SetDefaults(const VectorAttributes *atts)
{
    if(defaultAtts)
        delete defaultAtts;

    defaultAtts = new VectorAttributes(*atts);
}

